﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Storage;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Net;

namespace Antioch
{
    class ScreenPauseMenu : ScreenGeneralMenu
    {
		Base.GameStateModule GameState;
		Texture2D Frame;

		public ScreenPauseMenu(Base.GameStateModule GameState)
		{
			this.GameState = GameState;
		}

        public override void Initialize()
        {
			Frame = Content.Load<Texture2D>("Antioch.Content/frame");

            AddOption("Resume Game", ResumeGame);
			AddOption("Reset Chamber", ResetChamber);
			AddOption("Quit Game", QuitGame);

			this.OnBackPressed += () => PopScreen();
			this.DrawTitle = false;
			base.Initialize();
        }

        void ResumeGame()
        {
            PopScreen();
        }

		void ResetChamber()
		{
			GameState.ReloadCurrentChamber();
			PopScreen();
		}

		void QuitGame()
		{
			PushScreen(new ScreenConfirm("Are you sure?", QuitConfirmCallback));

		}

		void QuitConfirmCallback(bool result)
		{
			if (result)
			{
				PopScreen();
                GameState.AutosaveEnabled = false;
				GameState.BeginChangeMap("demo_Start", "");
			}
		}

		public override void Draw()
		{
			Rectangle SafeArea = GraphicsDevice.Viewport.TitleSafeArea;
			SpriteBatch.Begin();
			DrawFrame.Draw(SpriteBatch, Frame, 32, new Rectangle(SafeArea.X, SafeArea.Y, 256, 128));
			SpriteBatch.End();
			base.Draw();
		}
		
    }
}
